# -*- coding: UTF-8 -*-
'''
Created on 2012-4-14

@author: Who Eastblue
'''
import struct

def binArray2num(fmt, data):
    "data is a 'byte[]', convert and return a num by fmt" 
    num=struct.unpack(fmt, data)[0]
#    print 'num = %s' %(num)
    return num

def num2binArray(fmt, num):
    "return a 'byte[]' by fmt, the value is num"
    data=struct.pack(fmt,num)
    return data
